<template>
  <div class="container-content add">
    <el-row>
      <el-col :span="24">
        <h3 class="panel-title">编辑报告</h3>
      </el-col>
    </el-row>
    <!-- <el-divider class="divider"></el-divider> -->
    <el-form
      ref="formObject"
      :model="formObject"
      label-width="100px"
      :rules="formObjectRules"
      status-icon
      label-position="left"
    >
      <el-tabs
        v-model="activeName"
        type="card"
        @tab-click="handleTabClick"
        class="tabs"
      >
        <el-tab-pane label="基本信息" name="1">
          <el-row :gutter="30">
            <el-col :span="24">
              <el-form-item label="项目名称">
                <el-input placeholder="请选择项目" readonly>
                  <!-- <template slot="append"
                    ><i
                      class="el-input__icon el-icon-notebook-2"
                      @click="selectProject"
                    ></i
                  ></template> -->
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="selectProject"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="30">
            <el-col :span="8">
              <el-form-item label="项目编号">
                <el-input></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="屋顶方">
                <el-input></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="项目等级">
                <el-input></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="30">
            <el-col :span="8">
              <el-form-item label="所属地区">
                <el-input v-model="selectItem.region"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="注册资本">
                <el-input v-model="selectItem.registeredCapital"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="屋顶可利用面积" label-width="120px">
                <el-input v-model="selectItem.area"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="30">
            <el-col :span="8">
              <el-form-item label="企业性质">
                <el-select
                  v-model="selectItem.enterpriseNature"
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="item in enterpriseNatureOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="发电时间段峰平谷用电量(万度)"
                label-width="220px"
              >
                <el-input></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="变压器数量(台)" label-width="120px">
                <el-input
                  v-model="formObject.surveyReportEntity.transformerNumber"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="30">
            <el-col :span="24">
              <el-form-item label="变压器容量(kVA)" label-width="120px">
                <el-input
                  v-model="formObject.surveyReportEntity.transformerCapacity"
                  placeholder="按每台报数：（参考格式：xxxkVA+xxxkVA+xxxkVA+...）"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="30">
            <el-col :span="8">
              <el-form-item label="预计电费折扣">
                <el-input></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="上网电价(元/度)" label-width="120px">
                <el-input></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="加价电价(元/度)" label-width="120px">
                <el-input></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="30">
            <el-col :span="8">
              <el-form-item label="日照小时数(小时/年)" label-width="140px">
                <el-input></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="电压接入等级">
                <el-select
                  v-model="selectItem.voltageLevelValue"
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="item in levelOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="经纬度">
                <el-input
                  v-model="formObject.surveyReportEntity.latitude"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="30">
            <el-col :span="24">
              <el-form-item label="资料情况">
                <el-input type="textarea"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="30">
            <el-col :span="24">
              <el-form-item label="屋顶方门头照片" label-width="120px">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="总体规划" name="2">
          <el-row :gutter="30">
            <el-col>
              <el-form-item label="建模附件" label-width="140px">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col>
              <el-form-item label="施工方案" label-width="140px">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col>
              <el-form-item label="初步电弧路径规划图" label-width="140px">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col>
              <el-form-item label="备注">
                <el-input type="textarea"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="周边环境查勘" name="3">
          <el-row :gutter="30">
            <el-col>
              <el-form-item label="吊装位置" label-width="130px">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col>
              <el-form-item label="车辆进出通道" label-width="130px">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col>
              <el-form-item label="有无高楼建筑遮挡" label-width="130px">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col>
              <el-form-item label="到货物料堆放位置" label-width="130px">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col>
              <el-form-item label="备注">
                <el-input
                  type="textarea"
                  v-model="formObject.surveyReportEntity.remarks"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="结构" name="4">
          <el-row :gutter="30">
            <el-col>
              <el-form-item label="厂房内部屋顶照片" label-width="130px">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col>
              <el-form-item label="加固条件" label-width="130px">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="电气" name="5">
          <el-row :gutter="30">
            <el-col>
              <el-form-item label="配电系统相关图纸" label-width="130px">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col>
              <el-form-item label="配电房草图" label-width="130px">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col>
              <el-form-item label="变压器铭牌照片" label-width="130px">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col>
              <el-form-item label="电容柜容量照片" label-width="130px">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="项目特殊点" name="6">
          <el-row :gutter="30">
            <el-col>
              <el-form-item label="项目详情">
                <el-input type="textarea"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="资料" name="7">
          <el-row :gutter="30">
            <el-col>
              <el-form-item label="整体航拍、各专业照片" label-width="160px">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="屋顶状况" name="8">
          <el-table
            :data="formObject.surveyReportRoofEntities"
            style="width: 100%"
            border
          >
            <template #empty
              ><el-button plain type="primary" round @click="addNewRow"
                >添加新行</el-button
              ></template
            >
            <el-table-column label="操作" width="110">
              <template slot-scope="scope">
                <el-button
                  plain
                  icon="el-icon-plus"
                  @click="handleDataAdd_budget(scope.$index, scope.row)"
                ></el-button>
                <el-button
                  plain
                  icon="el-icon-minus"
                  @click="handleDataDelete_budget(scope.$index, scope.row)"
                ></el-button>
              </template>
            </el-table-column>
            <el-table-column
              type="index"
              width="50"
              label="序号"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="costType" label="厂区">
              <template slot-scope="scope">
                <el-input v-model="scope.row.costType" clearable></el-input>
              </template>
            </el-table-column>
            <el-table-column prop="roof" label="屋顶">
              <template slot-scope="scope">
                <el-input v-model="scope.row.budgetCost" clearable></el-input>
              </template>
            </el-table-column>
            <el-table-column prop="roofType" label="屋顶类型">
              <template slot-scope="scope">
                <el-select
                  v-model="scope.row.roofType"
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="item in roofTypeOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column prop="propertyRight" label="产权">
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.propertyRight"
                  clearable
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column prop="area" label="面积(㎡)">
              <template slot-scope="scope">
                <el-input v-model="scope.row.area" clearable></el-input>
              </template>
            </el-table-column>
            <el-table-column prop="componentPower" label="组件功率">
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.componentPower"
                  clearable
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column prop="componentNumber" label="组件数量">
              <template slot-scope="scope">
                <el-input
                  v-model="scope.row.componentNumber"
                  clearable
                ></el-input>
              </template>
            </el-table-column>
            <el-table-column prop="roofCapacity" label="屋顶装机容量">
              <template slot-scope="scope">
                <el-input v-model="scope.row.roofCapacity" clearable></el-input>
              </template>
            </el-table-column>
            <el-table-column label="初排图">
              <template>
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </template>
            </el-table-column>
            <el-table-column prop="loadLife" label="荷载">
              <template slot-scope="scope">
                <el-input v-model="scope.row.loadLife" clearable></el-input>
              </template>
            </el-table-column>
            <el-table-column prop="remarks" label="备注">
              <template slot-scope="scope">
                <el-input v-model="scope.row.remarks" clearable></el-input>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="屋顶查勘情况表" name="9">
          <el-row :gutter="30">
            <el-col>
              <el-form-item label="手绘现场草图">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="配电室情况" name="10">
          <el-row :gutter="30">
            <el-col>
              <el-form-item label="配电室平面图" label-width="130px">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col>
              <el-form-item label="光伏并网柜位置图" label-width="130px">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col>
              <el-form-item label="无功补偿器照片" label-width="130px">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
            <el-col>
              <el-form-item label="其他照片" label-width="130px">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="方案和报价" name="11">
          <el-row :gutter="30">
            <el-col>
              <el-form-item label="方案报价记录">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="缺少资料" name="12">
          <el-row :gutter="30">
            <el-col>
              <el-form-item label="其他资料">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="建筑照片" name="13">
          <el-row :gutter="30">
            <el-col>
              <el-form-item label="其他照片">
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :action="actionUrl"
                  :on-preview="handlePreview"
                  :on-remove="handleRemove"
                  :file-list="fileList"
                  :auto-upload="false"
                  list-type="picture"
                >
                  <el-button slot="trigger" size="small" type="primary"
                    ><i class="el-icon-plus"></i>添加</el-button
                  >
                </el-upload>
              </el-form-item>
            </el-col>
          </el-row>
        </el-tab-pane>
      </el-tabs>
      <el-form-item label-width="0px" style="margin-top: 20px">
        <el-button type="primary" @click="onSubmit">保存</el-button>
        <!-- <el-button type="primary" v-else @click="nextTab">下一步</el-button> -->
        <el-button @click="formRest('formObject')">取消</el-button>
      </el-form-item>
    </el-form>
    <!-- 选择项目 弹窗 -->
    <el-dialog title="选择项目" :visible.sync="selectProjectFlag" width="50%">
      <el-row class="filter-container">
        <el-col :span="24">
          <el-input
            placeholder="查询..."
            v-model="searchValue"
            class="input-with-select"
            @change="searchData"
          >
            <el-button
              slot="append"
              icon="el-icon-search"
              type="primary"
              @click="searchData"
            ></el-button>
          </el-input>
        </el-col>
      </el-row>
      <el-table
        ref="projectTable"
        :data="proTableData"
        stripe
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <!--  -->
        <el-table-column type="selection" width="55" align="center">
        </el-table-column>
        <el-table-column prop="id" label="id"> </el-table-column>

        <el-table-column
          prop="factoryArea"
          label="产权屋顶面积"
        ></el-table-column>
        <el-table-column prop="number" label="屋顶数量"></el-table-column>
        <el-table-column prop="creditQualified" label="企业征信">
          <template slot-scope="scope">
            <el-tag type="success" v-if="scope.row.creditQualified === 1"
              >合格</el-tag
            >
            <el-tag type="danger" v-else>不合格</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="isLeakage" label="漏水情况">
          <template slot-scope="scope">
            <el-tag type="danger" v-if="scope.row.isLeakage === 1">异常</el-tag>
            <el-tag type="success" v-else>正常</el-tag>
          </template>
        </el-table-column>

        <el-table-column prop="region" label="地区"> </el-table-column>
        <el-table-column prop="registeredCapital" label="注册资本">
        </el-table-column>
        <el-table-column prop="createTime" label="创建日期"> </el-table-column>
        <!-- <el-table-column label="操作">
          <template slot-scope="scope">
            <el-tooltip
              class="item"
              effect="dark"
              content="详情"
              placement="bottom"
            >
              <el-button
                plain
                icon="el-icon-more"
                @click="handleDetail(scope.$index, scope.row)"
              ></el-button>
            </el-tooltip>
            <el-tooltip
              class="item"
              effect="dark"
              content="编辑"
              placement="bottom"
            >
              <el-button
                type="primary"
                plain
                icon="el-icon-edit"
                @click="handleEdit(scope.$index, scope.row)"
              ></el-button>
            </el-tooltip>
            <el-tooltip
              class="item"
              effect="dark"
              content="删除"
              placement="bottom"
            >
              <el-button
                type="danger"
                plain
                icon="el-icon-delete"
                @click="handleDelete(scope.$index, scope.row)"
              ></el-button>
            </el-tooltip>
          </template>
        </el-table-column> -->
      </el-table>
      <el-pagination
        class="pagination"
        background
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </el-dialog>
  </div>
</template>
<script>
import {
  getList,
  editReportList,
  getDetailReportList,
  searchSurvey,
} from "@/api/system/survey";
import { actionUrl } from "@/api/system/upload";
export default {
  data() {
    return {
      activeName: "1",
      selectProjectFlag: false, //项目名称是否弹出
      total: 0, //项目名称弹窗分页
      searchValue: "", //项目名称弹窗搜索值
      selectItem: {}, //项目名称弹窗选中项

      formObject: {
        surveyReportEntity: {
          receipt: "屋顶方资源收集", //源单类型
          receiptNumber: "", //源单编号
          proName: "", //项目名称
          proNumber: "", //项目编号
          applyTime: "", //申请时间
          surveyBaseDataId: "", //关联勘测数据采集表
          isPhotograph: "", //能否航拍
          isStairs: "", //彩钢瓦房是否有爬梯
          isStairsQualified: "", //爬梯是否具备攀爬条件
          isTransformer: "", //是否拥有变压器产权
          isMeasureQualified: "", //测量是否具备条件
          isDisRoomIn: "", //配电房能否进入
          isComplete: "", //查勘装备是否齐全
          isCertificate: "", //是否拥有不动产权证
          isMeasure: "", //梁/柱/檩条是否测量
          transformerNumber: "", //变压器数量
          transformerCapacity: "", //变压器容量
          sunshineTime: "", //日照小时数
          roofArea: "", //屋顶可利用面积
        },
        surveyReportRoofEntities: [], //预算费用
      },
      proTableData: [],
      // 企业性质
      enterpriseNatureOptions: [],
      // 电压接入等级
      levelOptions: [],
      // 屋顶类型
      roofTypeOptions: [],
      fileList: [],
    };
  },
  methods: {
    // tab切换事件
    handleTabClick() {},
    //获取数据字典
    getSelectOptions() {
      // 项目模式
      // this.getDicts("sys_project_mode").then((res) => {
      //   console.log("res", res);
      //   if (res.code === 200) {
      //     this.proModeOptions = res.data.map((item) => {
      //       return {
      //         value: item.dictCode,
      //         label: item.dictLabel,
      //       };
      //     });
      //   }
      // });
      // 企业性质
      this.getDicts("sys_company_nature").then((res) => {
        if (res.code === 200) {
          this.enterpriseNatureOptions = res.data.map((item) => {
            return {
              value: item.dictCode,
              label: item.dictLabel,
            };
          });
        }
      });
      // // 渠道来源
      // this.getDicts("sys_resource").then((res) => {
      //   if (res.code === 200) {
      //     this.dataoptions = res.data.map((item) => {
      //       return {
      //         value: item.dictCode,
      //         label: item.dictLabel,
      //       };
      //     });
      //   }
      // });
      // // 电压接入等级
      this.getDicts("sys_voltage_level").then((res) => {
        if (res.code === 200) {
          this.levelOptions = res.data.map((item) => {
            return {
              value: item.dictCode,
              label: item.dictLabel,
            };
          });
        }
      });
      // // 屋顶类型
      this.getDicts("erp_roof_type").then((res) => {
        if (res.code === 200) {
          this.roofTypeOptions = res.data.map((item) => {
            return {
              value: item.dictCode,
              label: item.dictLabel,
            };
          });
        }
      });
      // // 厂房类型 erp_workshop_attr
      // this.getDicts("erp_workshop_attr").then((res) => {
      //   if (res.code === 200) {
      //     this.factoryNatureOptions = res.data.map((item) => {
      //       return {
      //         value: item.dictCode,
      //         label: item.dictLabel,
      //       };
      //     });
      //   }
      // });
      // // 屋面防水方式 roofWaterproofingOptions
      // this.getDicts("erp_water_method").then((res) => {
      //   if (res.code === 200) {
      //     this.roofWaterproofingOptions = res.data.map((item) => {
      //       return {
      //         value: item.dictCode,
      //         label: item.dictLabel,
      //       };
      //     });
      //   }
      // });
    },
    onSubmit() {
      editReportList(this.formObject).then((res) => {
        if (res.code === 200) {
          this.$message({
            message: "修改成功！",
            type: "success",
          });
          this.$router.push({ path: "/Survey/ReportSurvey" });
        }
      });
    },
    // 表单取消
    formRest(formName) {
      this.$refs[formName].resetFields();
      console.log("取消表单", this.$refs[formName]);
    },
    // 选择项目
    selectProject() {
      this.selectProjectFlag = true;
      getList().then((res) => {
        this.proTableData = res.rows;
        this.total = res.total;
      });
    },
    // 选择项目弹窗 搜索事件
    searchData() {
      let searchValue = this.searchValue;
      searchSurvey({ searchValue }).then((res) => {
        this.tableData = res.rows;
        console.log("请求成功", res);
      });
    },
    //选择项目弹窗 选中item
    handleSelectionChange(val) {
      if (val.length == 1) {
        this.selectItem = val[0];
        this.formObject.surveyReportEntity.surveyBaseDataId = val[0].id;
        if (this.selectItem.enterpriseNature) {
          let test = this.enterpriseNatureOptions.filter(
            (item) => item.value == this.selectItem.enterpriseNature
          );
          this.selectItem.enterpriseNature = test[0].label;
        }
        this.selectProjectFlag = false;
      }
    },
    //新增预算费用
    handleDataAdd_budget() {
      if (this.formObject.surveyReportRoofEntities == undefined) {
        this.formObject.surveyReportRoofEntities = [];
      }
      let obj = {};
      obj.costType = "";
      obj.budgetCost = "";
      obj.costContent = "";
      obj.remarks = "";
      this.formObject.surveyReportRoofEntities.push(obj);
    },
    //银行信息表单 删除行
    handleDataDelete_budget(index, row) {
      this.$confirm("请确认是否要删除此行?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.formObject.surveyReportRoofEntities.splice(index, 1);
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    //添加新行
    addNewRow(type) {
      this.handleDataAdd_budget();
    },
    getData(id) {
      getDetailReportList(id).then((res) => {
        if (res.code === 200) {
          let data = res.data;
          Object.keys(this.formObject).forEach((key) => {
            this.formObject[key] = data[key];
          });
        }
      });
    },
  },
  created() {
    this.getSelectOptions();
    this.getData(this.$route.query.id);
  },
};
</script>
<style lang="scss" scoped>
.divider {
  margin: 0;
}
// .tabs {
//   margin-top: 20px;
// }
.tip-input {
  display: flex;
  align-items: flex-start;
  p {
    margin: 10px 20px;
    color: #c0c4cc;
    font-size: 14px;
  }
}
.pagination {
  margin-top: 20px;
}
</style>
